package org.wishwork.api.stock.in;

import org.wishwork.api.stock.in.box.StockInBoxApi;
import org.wishwork.api.stock.in.box.StockInBoxResponse;
import org.wishwork.api.stock.in.box.request.StockInBoxRequest;
import org.wishwork.api.stock.in.confirm.StockInConfirmApi;
import org.wishwork.api.stock.in.confirm.StockInConfirmResponse;
import org.wishwork.api.stock.in.confirm.request.StockInConfirmRequest;
import org.wishwork.api.stock.in.query.StockInQueryApi;
import org.wishwork.api.stock.in.query.StockInQueryRequest;
import org.wishwork.api.stock.in.query.response.StockInQueryResponse;
import org.wishwork.api.stock.in.upload.StockInUploadApi;
import org.wishwork.api.stock.in.upload.StockInUploadResponse;
import org.wishwork.api.stock.in.upload.request.StockInUploadRequest;
import org.wishwork.context.Context;

import java.util.List;

/**
 * @description: 入库Api
 * @author: WangYX
 * @create: 2022-04-11 17:20
 * @Version: 1.0.0
 **/

public class StockInApi {

    private Context context;

    private final StockInQueryApi stockInQueryApi;
    private final StockInUploadApi stockInUploadApi;
    private final StockInConfirmApi stockInConfirmApi;
    private final StockInBoxApi stockInBoxApi;

    public StockInApi(Context context) {
        this.context = context;
        this.stockInQueryApi = new StockInQueryApi(context);
        this.stockInUploadApi = new StockInUploadApi(context);
        this.stockInConfirmApi = new StockInConfirmApi(context);
        this.stockInBoxApi = new StockInBoxApi(context);
    }

    /**
     * 采购入库查询
     *
     * @param stockInQueryRequest
     * @return
     * @throws Exception
     */
    public List<StockInQueryResponse> query(StockInQueryRequest stockInQueryRequest) throws Exception {
        return this.stockInQueryApi.business(stockInQueryRequest);
    }

    /**
     * 新建采购入库单（新）
     *
     * @param stockInUploadRequest
     * @return
     * @throws Exception
     */
    public StockInUploadResponse upload(StockInUploadRequest stockInUploadRequest) throws Exception {
        return this.stockInUploadApi.business(stockInUploadRequest);
    }

    /**
     * 入库单确认
     *
     * @param stockInConfirmRequest
     * @return
     * @throws Exception
     */
    public StockInConfirmResponse confirm(StockInConfirmRequest stockInConfirmRequest) throws Exception {
        return this.stockInConfirmApi.business(stockInConfirmRequest);
    }

    /**
     * 采购按箱入库
     *
     * @param stockInBoxRequests
     * @return
     * @throws Exception
     */
    public StockInBoxResponse box(List<StockInBoxRequest> stockInBoxRequests) throws Exception {
        return this.stockInBoxApi.business(stockInBoxRequests);
    }

}
